#include <iostream>
using namespace std;
#include<vector>
int main() {
    int n = 0, m = 0, q = 0;
    cin >> n >> m >> q;
    vector<vector<long long>> sum(n + 1, vector<long long>(m + 1, 0));
    long long tmp = 0;
    for (int i = 1; i <= n; i++)
    {
        long long tmpsum = 0;
        for (int j = 1; j <= m; j++)
        {
            cin >> tmp;
            tmpsum += tmp;
            sum[i][j] = tmpsum + (i > 1 ? sum[i - 1][j] : 0);

        }

    }
    for (int i = 0; i < q; i++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        long long output = sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];
        cout << output << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")
//3 4 3
//1 2 3 4
//3 2 1 0
//1 5 7 8
//1 1 2 2
//1 1 3 3
//1 2 3 4

///输出：8 25 32